package store.lunangangster.nodeflow.test.el.flow._if.test_component;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.concurrent.TimeUnit;
import org.springframework.stereotype.Component;
import store.lunangangster.nodeflow.core.component.WhileComponent;

@Component("judgeIsWorkingTime")
public class JudgeIsWorkingTimeComp extends WhileComponent {

  // int count = 0;

  LocalDateTime now;
  LocalDateTime outOfWork;

  @Override
  protected boolean processWhile() {
    // count ++;
    // return count <= 3;
    boolean isOutOfWork = false;


    now = LocalDateTime.now();
    outOfWork = LocalDate.now().atStartOfDay().plusHours(18);
    System.out.println("现在时间是: " + now + ", 下班时间是: " + outOfWork);
    isOutOfWork = now.isAfter(outOfWork);
    System.out.println(isOutOfWork ? "下班啦!" : "还要接着上班");
    try {
      TimeUnit.MILLISECONDS.sleep(500);
    } catch (Exception e) {
    }
    return !isOutOfWork;
  }
}
